package wangm.nettyhttp.channelhandler;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpRequestDecoder;
import io.netty.handler.codec.http.HttpRequestEncoder;


/**
 * server initializer handler
 *
 * @author zk
 * @date 2018-02-09 14:10
 */
public class HttpServerInitializer extends ChannelInitializer<SocketChannel>{

    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        ChannelPipeline pipeline = ch.pipeline();
        //request decode
        pipeline.addLast(new HttpRequestDecoder());
        pipeline.addLast(new HttpMessageServerHandler());
        //response encode
        pipeline.addLast(new HttpRequestEncoder());
    }
}
